package com.hzx.ssm.util;

import com.hzx.ssm.entity.Message;

import java.util.Comparator;
import java.util.List;

public class SortMessage {
    public static List<Message> sort(List<Message> allmessage){
        for(Message message:allmessage){
            System.out.println(message.getMessage_time());
        }
        allmessage.sort(new Comparator<Message>() {
            @Override
            public int compare(Message m1, Message m2) {

                return m1.getMessage_time().getTime()>m2.getMessage_time().getTime()?-1:1;
            }
        });
        System.out.println("--------------------");
        for(Message message:allmessage){
            System.out.println(message.getMessage_time());
        }
        return allmessage;
    }
}
